<?php
$readonly = '';
$disabled = '';
if($this->data['MAT_ID'] > 0){
    $USU_ID = $this->data['USU_ID'];
    $USU_NOME = $this->data['USU_NOME'];
    
    $readonly = 'readonly=""';
    $disabled = 'disabled=""';
}
else{
    $USU_ID = Zend_Auth::getInstance()->getStorage()->read()->USU_ID;
    $USU_NOME = Zend_Auth::getInstance()->getStorage()->read()->USU_NOME;
}

$PER_ID = Zend_Auth::getInstance()->getStorage()->read()->PER_ID;


?>
<div class="content-form">
    <h2><?php echo $this->titulo; ?></h2>
    <div id="content-form">
        <form id="form_matricula" action="" method="post" enctype="application/x-www-form-urlencoded">    
            <input type="hidden" id="MAT_ID" name="MAT_ID" value="<?php echo $this->data['MAT_ID']; ?>" />
            <input type="hidden" id="USU_ID" name="USU_ID" value="<?php echo $USU_ID; //Zend_Auth::getInstance()->getStorage()->read()->USU_ID; ?>" />    
            <input type="hidden" id="ALU_ID" name="ALU_ID" value="<?php echo $this->data['ALU_ID']; ?>" class="ajx_vlr_id find_alu_id" />    
            
            <div class="col">
                <div class="ln"><strong>Matriculador</strong> <input type="text" id="USU_NOME" name="USU_NOME" value="<?php echo $USU_NOME; //Zend_Auth::getInstance()->getStorage()->read()->USU_NOME; ?>" readonly="" /></div>
                <div class="ln" style="width: 380px;"><strong>Aluno</strong> <input type="text" id="ALU_NOM" name="ALU_NOM" value="<?php echo $this->data['ALU_NOM']; ?>" class="ajx_vlr_nom find_alu_nom" <?php echo $readonly; ?> />
                    <?php if($this->data['MAT_ID'] == 0) { ?><a href="javascript:void(0)" class="ajx_img clk_sel_alu"></a><?php } ?>
                </div>
                <div class="ln"><strong>Curso</strong> 
                <?php
                  /*
                    $cbs = new Admin_Model_DbTable_Cursobase();
                    $obj = new Admin_Model_DbTable_Curso();
                    $row = $obj->fetchAll('CUR_STA = 1 and CUR_ANO >= '.date('Y'))->toArray();
                    $arr = array('0'=>'Nenhum');
                    foreach($row as $r) 
                    {          
                        $cur_cbs = $cbs->fetchRow('CBS_ID = '.$r['CBS_ID']);
                        $arr[$r['CUR_ID']] = $cur_cbs['CBS_NOM'] .', Turno: '. dominio::getTurno($r['TUR_ID']). ', Turma:'.$r['CUR_TRM']. ', Qtd: '.Operacoes::vagasCurso($r['CUR_ID']) .' / '.  $r['CUR_NMRMAXALU'];
                    }
                  */
                    $arr = dominio::getTurma();
                    
                    if($disabled == '') $disabled = 'required=""';
                    $html = '<select id="CUR_ID" name="CUR_ID" class="curso" '.$disabled.'>';
                    foreach($arr as $key => $r){ 
                        $selected = $key == $this->data['CUR_ID']  ? 'selected=""':'';            
                        $html .= '<option '.$selected.' value="'.$key.'">'.$r.'</option>'; 
                    }
                    echo $html .= '</select>';
                ?>    
                </div>
                <div class="ln"><strong>Valor Entrada</strong> <input type="text" id="MAT_VLRENT" name="MAT_VLRENT" value="<?php echo $this->data['MAT_VLRENT']; ?>" class="valor" <?php echo $readonly; ?> /></div>
                <div class="ln"><strong>Valor do Curso</strong> <input type="text" id="CUR_VLR" name="CUR_VLR" value="<?php echo $this->data['CUR_VLR']; ?>" class="valor cur_val" readonly="" /></div>
                <div class="ln" id="CUR_VLRPRO-label"><strong>Valor Promocional</strong> <input type="text" id="CUR_VLRPRO" name="CUR_VLRPRO" value="<?php echo $this->data['CUR_VLRPRO']; ?>" class="valor cur_valpro" readonly="" /></div>
                
            </div>
            
            <div class="col">
                <div class="ln" style="width: 430px;" ><strong>Valor Diferenciado</strong> <input type="text" id="MAT_VLRDIR" name="MAT_VLRDIR" value="<?php echo $this->data['MAT_VLRDIR']; ?>" class="valor cur_valbol" readonly="" />
                    <?php if($this->data['MAT_ID'] == 0) { ?><a href="javascript:void(0)" class="clk_lib_aces">LIBERAR VALOR</a><input id="_user" name="_user" type="hidden" value="" /><input id="_key" name="_key" type="hidden" value="" /> <?php } ?>
                </div>
                <div class="ln"><strong>Forma de Pagamento</strong> 
                <?php
                    $disabled = '';
                    if($this->data['MAT_ID'] > 0) $disabled = 'disabled=""';
                    else $disabled = ''; //required=""
                    
                    $html = '<select id="FOR_ID" name="FOR_ID" class="tam_med for_pag" '.$disabled.'>';
                    $html .= '<option value="">Nenhum</option>'; 
                    $obj = new Admin_Model_DbTable_Formaspagamento();
                    $row = $obj->fetchAll()->toArray();
                    foreach($row as $r){
                        $selected = $r['FOR_ID'] == $this->data['FOR_ID']  ? 'selected=""':'';            
                        $html .= '<option '.$selected.' value="'.$r['FOR_ID'].'">'.$r['FOR_NOM'].'</option>'; 
                    }
                    echo $html .= '</select>';
                ?>    
                </div>
                <div class="ln"><strong>Quantidade de Parcelas</strong> <input type="text" id="MAT_QTDPAR" name="MAT_QTDPAR" value="<?php echo $this->data['MAT_QTDPAR']; ?>" class="parcelas numero" readonly=""  /></div>
                <div class="ln" id="MAT_QTDPARDIR-label"><strong>Qtd. de Parcelas Diferenciado</strong> <input type="text" id="MAT_QTDPARDIR" name="MAT_QTDPARDIR" value="<?php echo $this->data['MAT_QTDPARDIR']; ?>" class="numero" readonly="" /></div>
                <div class="ln" id="CUR_PERDSC-label"><strong>Desconto à vista %</strong> <input type="text" id="CUR_PERDSC" name="CUR_PERDSC" value="<?php echo $this->data['CUR_PERDSC']; ?>" class="valor" readonly="" /></div>
                
                <div class="ln"><strong>Status</strong> <br>
                    <label><input type="radio" name="MAT_STA" id="MAT_STA" value="1" class="tpotmp" <?php if($this->data['MAT_STA'] == '' || $this->data['MAT_STA'] == 1) echo 'checked=""'; ?> <?php if($PER_ID > 1) echo $disabled;?> > Ativo</label> &nbsp;
                    <label><input type="radio" name="MAT_STA" id="MAT_STA" value="0" class="tpotmp" <?php if($this->data['MAT_STA'] == '0') echo 'checked=""'; ?> <?php if($PER_ID > 1) echo $disabled;?> > Inativo</label>
                </div>
                
                <div>
                    <?php if($this->data['MAT_ID'] == 0 || $PER_ID == 1){ ?>
                    <input type="submit" name="submit" id="submitbutton" value="Salvar" class="btn-frm">
                    <?php } ?>
                    <a href="<?php echo $this->urlmodulo.'/'.$this->controller; ?>" class="btn-frm">voltar</a>
                </div>
                
            </div>
        </form>
    </div>
</div>
<div id="dialog"></div>
<script>
dataPicker($('#CUR_DATPRO'));
</script>
